#!/bin/sh
set -e

set -a
if [ -f ../../.env ]; then . ../../.env; fi
DATABASE_URL=${PG_EXAMPLE_DATABASE_URL}
set +a

for dir in $(find . -maxdepth 1 -mindepth 1 -type d); do
  cd $dir

  if [ -d "migrations" ]; then
    ../../../bin/diesel database reset
  fi

  cargo test
  cd ..
done
